home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-06-19 | 8.9 KB | 396 lines | [TEXT/MPS ] |
- ; Not!
- ;
- ; A highly sophisticated hack — Not!
- ;
- ; by Darin Adler and Nevin Liber
- ; extensive help from Greg Marriott, Jim Reekes, Philip Nguyen and Jeff Miller — Not!
- ; idea suggested by Waldemar Horwat
- ;
- ; The idea is to notice modal dialogs that contain some negative message.
- ; If they also contain a button with the word OK, it is changed to Not,
- ; and a sound is played when the button is hit ("Not!"). Also, the negatives
- ; are all changed to positives.
- ;
- ; Highlights
- ;
- ; all programming done on the night of the 1992 MacHack hack contest
- ; all programming done in under 2 hours
- ; 3 patches
- ;
- ; Ideas
- ;
- ; handle Yes/No and Save/Don’t Save
- ; do better checking of the grammar of the sentence
- ; play QuickTime movie of Wayne’s World clip instead of just sound
- ; add help balloons
- ; rewrite in C
- ; rewrite in C++
- ; build into Macintosh system software
- ; get a life
- ; add ! mark after Not
-
- INCLUDE 'QuickEqu.a'
- INCLUDE 'SysEqu.a'
- INCLUDE 'ToolEqu.a'
- INCLUDE 'Traps.a'
-
- DrawDialogTrap EQU $A981
- DrawTextTrap EQU $A885
- ModalDialogTrap EQU $A991
-
- ;---------------------------------------------------------------------------------
- ;
- ; MAIN
- ; Install our patches
- ;
- ;---------------------------------------------------------------------------------
-
- PatchIt MAIN EXPORT
- IMPORT PatchStart, PatchEnd
- IMPORT OldDrawDialogTrapAddress,NewDrawDialogTrapCode
- IMPORT OldDrawTextTrapAddress,NewDrawTextTrapCode
- IMPORT OldModalDialogTrapAddress,NewModalDialogTrapCode
- IMPORT DetachedSoundResource
-
- shiftByte EQU 7 ; byte and
- shiftBit EQU 0 ; bit offset in key map for shift key
-
- CLR.B -(SP) ; boolean result for Button
- _Button
- MOVE.B (SP)+, D0 ; get and test result
- BNE ExitWithFailure ; get outta town if button is down...
- PEA myKeys ; my copy of the key map
- _GetKeys
- LEA myKeys, A0
- BTST #shiftBit, shiftByte(A0) ; check the shift key
- BNE ExitWithFailure ; get outta town if shift key is down...
-
- CopyPatchCode
- LEA PatchEnd, A2 ; use the end and the beginning
- LEA PatchStart, A1 ; of the patch to calculate its
- SUBA.L A1, A2 ; size
- MOVE.L A2, D0
- _NewPtr sys ; allocate space for the patch
- BEQ.S PatchOK ; if we succeed, copy the patch into sysheap
- BRA ExitWithFailure ; otherwise, die
-
- PatchOK
- EXG A0, A1 ; A1 has source, A0 has dest, but _BlockMove needs them swapped
- MOVE.L A2, D0 ; size of block from calculation goes in D0
- _BlockMove ; IM says this can't fail (hardy har har...)
-
- MOVE.W #DrawDialogTrap,D0 ; get old trap address and put it in the patch
- _GetTrapAddress ; so it can call the real trap code
- LEA OldDrawDialogTrapAddress-PatchStart(A1), A2
- MOVE.L A0, (A2)
-
- LEA NewDrawDialogTrapCode-PatchStart(A1), a0
- move.l a0, d0
- _StripAddress
- move.l d0, a0
- MOVE.W #DrawDialogTrap, D0
- _SetTrapAddress ; load up our address in the trap table
-
- MOVE.W #DrawTextTrap,D0 ; get old trap address and put it in the patch
- _GetTrapAddress ; so it can call the real trap code
- LEA OldDrawTextTrapAddress-PatchStart(A1), A2
- MOVE.L A0, (A2)
-
- LEA NewDrawTextTrapCode-PatchStart(A1), a0
- move.l a0, d0
- _StripAddress
- move.l d0, a0
- MOVE.W #DrawTextTrap, D0
- _SetTrapAddress ; load up our address in the trap table
-
- MOVE.W #ModalDialogTrap,D0 ; get old trap address and put it in the patch
- _GetTrapAddress ; so it can call the real trap code
- LEA OldModalDialogTrapAddress-PatchStart(A1), A2
- MOVE.L A0, (A2)
-
- LEA NewModalDialogTrapCode-PatchStart(A1), a0
- move.l a0, d0
- _StripAddress
- move.l d0, a0
- MOVE.W #ModalDialogTrap, D0
- _SetTrapAddress ; load up our address in the trap table
-
- _GetZone
- move.l a0,-(sp)
- move.l SysZone,a0
- _SetZone
- lea DetachedSoundResource-PatchStart(a1),a2
- subq #4,sp
- move.l #'snd ',-(sp)
- move.w #1,-(sp)
- _Get1IxResource
- move.l (sp),(a2)
- move.l (sp),a0
- _HNoPurge
- _DetachResource
- move.l (sp)+,a0
- _SetZone
-
- ExitWithSuccess
- ExitWithFailure
-
- AllDone
- RTS ; bye bye
-
- myKeys
- DCB.B 128/8, 0 ; KeyMap structure for GetKeys
-
- ENDMAIN
-
- ;---------------------------------------------------------------------------------
- ;
- ; PROC PatchStart
- ;
- ; Just a place holder for the patch size calculation.
- ;
- ;---------------------------------------------------------------------------------
-
- PatchStart PROC EXPORT
- ENDP
-
- ;---------------------------------------------------------------------------------
- ;
- ; NewDrawDialogTrapCode goes here
- ;
- ;---------------------------------------------------------------------------------
- NewDrawDialogTrapCode PROC EXPORT
- EXPORT OldDrawDialogTrapAddress
- IMPORT InsideDrawDialog
-
- lea InsideDrawDialog,a0
- st (a0)
-
- move.l 4(sp),-(sp)
- jsr $12345678
- OldDrawDialogTrapAddress EQU *-4
-
- lea InsideDrawDialog,a0
- clr.b (a0)
-
- move.l (sp)+,(sp)
- rts
-
- ENDP
-
- ;---------------------------------------------------------------------------------
- ;
- ; NewDrawTextTrapCode goes here
- ;
- ;---------------------------------------------------------------------------------
- NewDrawTextTrapCode PROC EXPORT
- EXPORT OldDrawTextTrapAddress
- EXPORT InsideDrawDialog
-
- ;patch DrawText
- ;if inside DrawDialog and text drawn contains "not " or "n’t"
- ; remove the matched string
- ; change title of control from "OK" to "Not"
-
- lea InsideDrawDialog,a0
- tst.b (a0)
- beq DoOld
-
- ; check text for "not " or "n’t"
- move.l 8(sp),a0
- add.w 6(sp),a0
- moveq #0,d0
- move.w 4(sp),d0
- _PtrToHand
- bne DoOld
-
- movem.l a2/a3/d3,-(sp)
- move.l a0,-(sp)
- moveq #0,d3
-
- lea NotStrings,a2
- NextString
- tst.b (a2)
- beq.s DoneStrings
- move.l a2,a3
- Repeat
- move.l (sp),a0
- subq #4,sp
- move.l a0,-(sp)
- clr.l -(sp)
- moveq #0,d0
- move.b (a2)+,d0
- move.l a2,-(sp)
- move.l d0,-(sp)
- add.l d0,a2
- moveq #0,d0
- move.b (a2)+,d0
- move.l a2,-(sp)
- move.l d0,-(sp)
- add.l d0,a2
- _Munger
- tst.l (sp)+
- bmi.s NextString
- moveq #1,d3
- move.l a3,a2
- bra.s Repeat
-
- DoneStrings
- tst.l d3
- beq.s Boredom
-
- Excitement
- subq #4,sp
- _FrontWindow
- move.l (sp)+,a0
- move.l wControlList(a0),a2
-
- TryNext
- move.l a2,d0
- beq.s Boredom
-
- move.l (a2),a0
- moveq #0,d0
- lea contrlTitle(a0),a0
- move.b (a0)+,d0
- swap d0
- lea #'OK',a1
- move.b (a1)+,d0
- _CmpString
- beq.s SuperThrills
- move.l (a2),a0
- moveq #0,d0
- lea contrlTitle(a0),a0
- move.b (a0)+,d0
- swap d0
- lea #'Not',a1
- move.b (a1)+,d0
- _CmpString
- beq.s SuperThrills2
- move.l (a2),a0
- move.l nextControl(a0),a2
- bra.s TryNext
-
- SuperThrills
- move.l a2,-(sp)
- pea #'Not'
- _SetCTitle
-
- SuperThrills2
- move.l (sp),a0
- _HLock
- move.l (a0),-(sp)
- clr.w -(sp)
- _GetHandleSize
- move.w d0,-(sp)
- bsr.s DoOld
-
- move.l (sp)+,a0
- _DisposeHandle
- movem.l (sp)+,a2/a3/d3
-
- move.l (sp)+,a0
- addq #8,sp
- jmp (a0)
-
- Boredom
- move.l (sp)+,a0
- _DisposeHandle
- movem.l (sp)+,a2/a3/d3
-
- DoOld
- jmp $12345678
- OldDrawTextTrapAddress EQU *-4
-
- InsideDrawDialog dc.b 0
- align
-
- NotStrings
- dc.b 'cannot','can'
- dc.b 'not ',''
- dc.b 'won’t','will'
- dc.b 5,('w'),('o'),('n'),39,('t'),'will'
- dc.b 'can’t','can'
- dc.b 5,('c'),('a'),('n'),39,('t'),'can'
- dc.b 'n’t',''
- dc.b 3,('n'),39,('t'),''
- dc.b 0
-
- ENDP
-
- ;---------------------------------------------------------------------------------
- ;
- ; NewModalDialogTrapCode goes here
- ;
- ;---------------------------------------------------------------------------------
- NewModalDialogTrapCode PROC EXPORT
- EXPORT OldModalDialogTrapAddress,DetachedSoundResource
-
- ;patch ModalDialog
- ;if chosen item is a button with title "Not"
- ; play sound "Not"
-
- move.l 8(sp),-(sp)
- move.l 8(sp),-(sp)
-
- jsr $12345678
- OldModalDialogTrapAddress EQU *-4
-
- link a6,#-300
-
- subq #4,sp
- _FrontWindow
- move.l 8(a6),a0
- move.w (a0),-(sp)
- pea -2(a6)
- pea -6(a6)
- pea -14(a6)
- _GetDItem
- move.w -2(a6),d0 ; get item type
- cmp.w #4,d0
- beq.s GotButton
- cmp.w #132,d0
- bne.s Return
-
- GotButton
- move.l -6(a6),-(sp)
- pea -300(a6)
- _GetCTitle
-
- moveq #0,d0
- lea.l -300(a6),a0
- move.b (a0)+,d0
- swap d0
- lea #'Not',a1
- move.b (a1)+,d0
- _CmpString
- bne.s Return
-
- subq #2,sp
- clr.l -(sp)
- move.l DetachedSoundResource,-(sp)
- clr.b -(sp)
- _SndPlay
-
- Return
- unlk a6
-
- move.l (sp)+,a0
- addq #8,sp
- jmp (a0)
-
- DetachedSoundResource dc.l 0
-
- ENDP
-
- ;---------------------------------------------------------------------------------
- ;
- ; PROC PatchEnd
- ;
- ; Just a place holder for the patch size calculation.
- ;
- ;---------------------------------------------------------------------------------
-
- PatchEnd PROC EXPORT
- ENDP
-
- END